﻿
Partial Class FinalSchedule
    Inherits System.Web.UI.Page

    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try

            Dim Action As String = ""
            Dim sTarget As String = ""
            Dim sValue As String = ""
            If Not IsNothing(Request.QueryString("action")) Then
                Action = Request.QueryString("action").Trim
            End If
            If Not IsNothing(Request.QueryString("target")) Then
                sTarget = Request.QueryString("target").Trim
            End If
            If Not String.IsNullOrEmpty(sTarget) And Not IsNothing(Request.QueryString(sTarget)) Then
                sValue = Request.QueryString(sTarget).Trim
            End If
            If Not String.IsNullOrEmpty(Action) And Not String.IsNullOrEmpty(sTarget) And Not String.IsNullOrEmpty(sValue) Then
                If Action = "save" Then
                    Select Case sTarget.Split("_")(0)
                        Case "Room"
                            'do room behave here
                            mDataStore.mUpdateRoomSession(sValue, sTarget.Split("_")(1), sTarget.Split("_")(2))
                        Case "Lecturer"
                            'do lecturer action
                            If sTarget.Split("_")(1) = "new" Then
                                mDataStore.mInsertLecturerSession(sValue, sTarget.Split("_")(2), sTarget.Split("_")(3))
                            Else
                                mDataStore.mUpdateLecturerSession(sValue, sTarget.Split("_")(1))
                            End If
                        Case "Student"
                            'do Student
                            mDataStore.mDeleteStudentSession(sTarget.Split("_")(4))
                            mDataStore.mUpdateStudentSession(sTarget.Split("_")(1), sTarget.Split("_")(2), sTarget.Split("_")(3), sValue)
                    End Select

                    'get target
                    'analyze target
                    'on case to perform
                ElseIf Action = "remove" Then
                    'get target
                    If sTarget.Split("_")(0) = "student" Then
                        mDataStore.mDeleteStudentSession(Request.QueryString("hiddenID").Trim)
                    ElseIf sTarget.Split("_")(0) = "lecturer" Then
                        mDataStore.mDeleteLecturerSession(Request.QueryString("hiddenID").Trim)
                    End If
                    'identify lecturer or student
                    'behave
                End If
            End If
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Sub


End Class


